var xmpp = require('node-xmpp');
var argv = process.argv;

/*
if (argv.length < 6) {
        console.error('Usage: node send_message.js <my-jid> <my-password> <my-text> <jid> [jid2] ... [jidN]');
        process.exit();
}
*/

var cl = new xmpp.Client({
        jid: 'cylee@openfire',
        password: 'welcome1'
});

cl.addListener('online', function() {
        console.log('user is online...');

        var to = 'sejoonlim@openfire';
        console.log('send message to ' + to);
        cl.send(new xmpp.Element('message', {to: to, type: 'chat'}).c('body').t('This is notification message.'));

        // nodejs has nothing left to do and will exit
        cl.end();
});

cl.addListener('error', function(e) {
        console.error(e);
        process.exit(1);
});